<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta http-equiv="pragma" content="no-cache" />
	<link rel="stylesheet" href="/css/style.css" type="text/css"/>
	<script type="text/javascript" src="/js/jquery.js"></script>
	<script type="text/javascript" src="/js/util.js"></script>
</head>
<script type="text/javascript">
//////////////////////////////////////////////////////////////////////
////  email = "wenpin.qian@happyelements.com"                     ////
////  team = "Athene"                                             ////
////  warnings = "This is generated page,Do Not Modify!";         ////
////  tips = "Opera & IE not supported|Chrome & Safari sugguested"////
//////////////////////////////////////////////////////////////////////
window.returnValue=0;
var skillId = null;
var getskillUrl = "/skill/get/";
var editskillUrl = "/skill/edit/";
var currentskill = null;
$(document).ready(function() {
	skillId = window.dialogArguments;
	$.ajax({
		   type: "GET",
		   url: getskillUrl,
		   data: "skillId=" + skillId,
		   dataType: "json",
		   success: function(data) {
			   if(data.code > 0) {
				   var result = data.result;
				   $("#skillId").val(result.skillId);
				   $("#deployId").val(result.deployId);
				   $("#name").val(result.name);
				   $("#desc").val(result.desc);
				   $("#category").val(result.category);
				   $("#targetType").val(result.targetType);
				   $("#damage").val(result.damage);
				   $("#triggerDamage").val(result.triggerDamage);
				   $("#status").val(result.status);
				   $("#triggerStatus").val(result.triggerStatus);
				   $("#trigger").val(result.trigger);
				   $("#property").val(result.property);
				   $("#changeFury").val(result.changeFury);
				   $("#sound").val(result.sound);
				   $("#skillres").val(result.skillres);
				   				   
				   currentskill = result; 
				   listselectors();
				   window.returnValue=1;
			   }else {
				   errDialog(data.message);
			   }
		   }
	});
});

function listselectors() {
}

function editskill() {
	var skillIdParam = "skillId=" + skillId;
	var nameValue = $("#name").val();
	if(!checkString("名字",nameValue,false)) {
		return;
	}
	var nameParam = "name=" + xparseString(nameValue);
		
	var descValue = $("#desc").val();
	if(!checkString("描述",descValue,false)) {
		return;
	}
	var descParam = "desc=" + xparseString(descValue);
		
	var categoryValue = $("#category").val();
	
	var categoryParam = "category=" + categoryValue;
		
	var targetTypeValue = $("#targetType").val();
	
	var targetTypeParam = "targetType=" + targetTypeValue;
		
	var damageValue = $("#damage").val();
	
	var damageParam = "damage=" + damageValue;
		
	var triggerDamageValue = $("#triggerDamage").val();
	
	var triggerDamageParam = "triggerDamage=" + triggerDamageValue;
		
	var statusValue = $("#status").val();
	
	var statusParam = "status=" + statusValue;
		
	var triggerStatusValue = $("#triggerStatus").val();
	
	var triggerStatusParam = "triggerStatus=" + triggerStatusValue;
		
	var triggerValue = $("#trigger").val();
	
	var triggerParam = "trigger=" + triggerValue;
		
	var propertyValue = $("#property").val();
	
	var propertyParam = "property=" + propertyValue;
		
	var changeFuryValue = $("#changeFury").val();
	if(!checkInteger("怒气改变值",changeFuryValue,false)) {
		return;
	}
	var changeFuryParam = "changeFury=" + xparseInt(changeFuryValue);
		
	var soundValue = $("#sound").val();
	if(!checkString("音效",soundValue,false)) {
		return;
	}
	var soundParam = "sound=" + xparseString(soundValue);
		
	var skillresValue = $("#skillres").val();
	
	var skillresParam = "skillres=" + skillresValue;
			
	$.ajax({
		   type: "POST",
		   url: editskillUrl,
		   		   data:  skillIdParam + '&' +  nameParam  +'&'+   descParam  +'&'+   categoryParam  +'&'+   targetTypeParam  +'&'+   damageParam  +'&'+   triggerDamageParam  +'&'+   statusParam  +'&'+   triggerStatusParam  +'&'+   triggerParam  +'&'+   propertyParam  +'&'+   changeFuryParam  +'&'+   soundParam  +'&'+   skillresParam  ,
		   dataType: "json",
		   success: function(data) {
			   if(data.code > 0) {
			   	   beforeWindowClose();
				   window.close();
			   }else {
				   errDialog(data.message);
			   }
		   }
	});
}

	
	
	
	
			function adddamage() {
			var damagestr = $('#damage').val();
			var returnCallback = function(retvalue) {
				$('#damage').val(retvalue);
			}
			openDialog("/pages/customer/SkillDamage.html",damagestr,"dialogWidth:600px;dialogHeight:600px;status:no;help:no;center:yes",returnCallback);
		}
	
			function addtriggerDamage() {
			var triggerDamagestr = $('#triggerDamage').val();
			var returnCallback = function(retvalue) {
				$('#triggerDamage').val(retvalue);
			}
			openDialog("/pages/customer/SkillDamage.html",triggerDamagestr,"dialogWidth:600px;dialogHeight:600px;status:no;help:no;center:yes",returnCallback);
		}
	
			function addstatus() {
			var statusstr = $('#status').val();
			var returnCallback = function(retvalue) {
				$('#status').val(retvalue);
			}
			openDialog("/pages/customer/SkillStatus.html",statusstr,"dialogWidth:600px;dialogHeight:600px;status:no;help:no;center:yes",returnCallback);
		}
	
			function addtriggerStatus() {
			var triggerStatusstr = $('#triggerStatus').val();
			var returnCallback = function(retvalue) {
				$('#triggerStatus').val(retvalue);
			}
			openDialog("/pages/customer/SkillStatus.html",triggerStatusstr,"dialogWidth:600px;dialogHeight:600px;status:no;help:no;center:yes",returnCallback);
		}
	
			function addtrigger() {
			var triggerstr = $('#trigger').val();
			var returnCallback = function(retvalue) {
				$('#trigger').val(retvalue);
			}
			openDialog("/pages/customer/SkillTrigger.html",triggerstr,"dialogWidth:600px;dialogHeight:600px;status:no;help:no;center:yes",returnCallback);
		}
	
			function addproperty() {
			var propertystr = $("#property").val();
			var returnCallback = function(retvalue) {
				$('#property').val(retvalue);
			}
			openDialog("/pages/core/Array.html",["/pages/customer/PropertyOPEntity.html",propertystr],"dialogWidth:600px;dialogHeight:600px;status:no;help:no;center:yes",returnCallback);
		}
	
	
	
	
function openResource(fieldname,dependfield) {
	var param = "";
	if(dependfield!="") {
		param = $("#" + dependfield).val()
		if(param == null || param == "") {
			alert("你先把【" + $("#lbl_" + dependfield).html() + "】填了再上传");
			return;
		}
	}
	resourceDialog("skill",$("#" + fieldname).val(),param,function(result) {
		if(result != undefined && result != "") {
			$("#" + fieldname).val(result);
		}
	});
}

function beforeWindowClose() {
	if(window.returnCallback) {
		window.returnCallback(window.returnValue);
	}
	window.onbeforeunload = null;
	return true;
}

</script>
<body onunload="beforeWindowClose()">
	<div class="addarea">
	<form action="/skill/add" method="post">
		<table>
			<tbody>
				<tr>
					<td>ID</td><td><input type="text" id="skillId" name="skillId" disabled/></td>
					<td>发布Id</td><td><input type="text" id="deployId" name="deployId" disabled/></td>
				</tr>
			</tbody>
		</table>
		<table>
			<tbody>				
					<tr>					<td>
						<label for="name" id="lbl_name">名字</label>
													<input type="text" id="name" name="name" /><span class="tips">[文字]</span>
											</td>
									
										<td>
						<label for="desc" id="lbl_desc">描述</label>
													<input type="text" id="desc" name="desc" /><span class="tips">[文字]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="category" id="lbl_category">分类</label>
																				<select id="category" name="category">
								
									<option value="10">普通攻击</option>
								
									<option value="11">技能攻击</option>
								
									<option value="12">辅助攻击</option>
								
									<option value="13">怒气攻击</option>
								
									<option value="21">常效被动</option>
								
									<option value="22">触发被动</option>
								
									<option value="23">回合被动</option>
															</select>
											</td>
									
										<td>
						<label for="targetType" id="lbl_targetType">目标类型</label>
																				<select id="targetType" name="targetType">
								
									<option value="0">未选择</option>
								
									<option value="1">敌方随机单个目标</option>
								
									<option value="2">敌方全体目标</option>
								
									<option value="3">自己</option>
								
									<option value="4">己方随机单个目标</option>
								
									<option value="5">己方全体目标</option>
								
									<option value="6">随机单个目标</option>
								
									<option value="7">全体目标</option>
								
									<option value="8">攻击者</option>
								
									<option value="9">敌方丁字塔</option>
								
									<option value="10">敌方横向</option>
								
									<option value="11">敌方纵向</option>
								
									<option value="12">自己移动</option>
															</select>
											</td>
					</tr>				
					<tr>					<td>
						<label for="damage" id="lbl_damage">固有伤害</label>
													<input type="text" id="damage" name="damage" value="{}" disabled/>
							<input type="button" value="..." onclick="adddamage()"/>
											</td>
									
										<td>
						<label for="triggerDamage" id="lbl_triggerDamage">触发伤害</label>
													<input type="text" id="triggerDamage" name="triggerDamage" value="{}" disabled/>
							<input type="button" value="..." onclick="addtriggerDamage()"/>
											</td>
					</tr>				
					<tr>					<td>
						<label for="status" id="lbl_status">基础状态</label>
													<input type="text" id="status" name="status" value="{}" disabled/>
							<input type="button" value="..." onclick="addstatus()"/>
											</td>
									
										<td>
						<label for="triggerStatus" id="lbl_triggerStatus">触发状态</label>
													<input type="text" id="triggerStatus" name="triggerStatus" value="{}" disabled/>
							<input type="button" value="..." onclick="addtriggerStatus()"/>
											</td>
					</tr>				
					<tr>					<td>
						<label for="trigger" id="lbl_trigger">触发器</label>
													<input type="text" id="trigger" name="trigger" value="{}" disabled/>
							<input type="button" value="..." onclick="addtrigger()"/>
											</td>
									
										<td>
						<label for="property" id="lbl_property">属性列表</label>
													<input type="text" id="property" name="property" value="[]" disabled/>
							<input type="button" value="..." onclick="addproperty()"/>
											</td>
					</tr>				
					<tr>					<td>
						<label for="changeFury" id="lbl_changeFury">怒气改变值</label>
													<input type="text" id="changeFury" name="changeFury" /><span class="tips">[整数]</span>
											</td>
									
										<td>
						<label for="sound" id="lbl_sound">音效</label>
													<input type="text" id="sound" name="sound" /><span class="tips">[文字]</span>
											</td>
					</tr>				
					<tr>					<td>
						<label for="skillres" id="lbl_skillres">资源SWF</label>
													<input type="text" id="skillres" name="skillres" disabled/>
							<input type="button" value="..." onclick="openResource('skillres','')"/><span class="tips">[资源]</span>
											</td>
												</tbody>
		</table>
		<input type="button" onclick="editskill()" value="修改"/>
	</form>
	</div>
</body>